<?php

$per_page = 10;//每页显示的条数
$total_num = count($data);//总条数
$total_page = ceil($total_num / $per_page);//向上取整

$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;//获取当前页码
//页码合理性判断的第二种方式，两种方式任选其一即可

$page = max($page,1);
$page = min($page,$total_page);

//页码合理性判断的第二种方式，任选其一即可
$pre_page = ($page - 1) < 1 ? $page : ($page-1);
$next_page =($page + 1) > $total_page ? $page : ($page+1);
// $pre_page = $page - 1;
// $next_page =$page + 1;
// $page_1=$page+1;
// $page_2=$page+2;
// $page_3=$page+3;

$end_index = $per_page*$page - 1;
$end_index = min($end_index,$total_num - 1);
$start_index = ($per_page*($page - 1)-1)+1;

?>


